import { execute } from '@/store/baseAction'
import * as postApi from '@/api/post'

// 发帖
export function publish (context, payload) {
    return execute(postApi.publish(payload))
}

// 删帖
export function deletePost (context, payload) {
    return execute(postApi.deletePost(payload))
}

// 根据帖子Id获取帖子
export function getById (context, postId) {
    return execute(postApi.getById(postId))
}

// 分页获取当前用户的贴子
export function pageCurrentPosts (context, payload) {
    return execute(postApi.pageCurrentPosts(payload))
}

// 分页获取用户的帖子
export function pageAuthorPosts (context, payload) {
    return execute(postApi.pageAuthorPosts(payload))
}

// 分页获取区域帖子
export function pageAreaPost (context, areaPageInfo) {
    return execute(postApi.pageAreaPost(areaPageInfo))
}

// 推荐
export function recommend () {
    return execute(postApi.recommend())
}

// 获取当前用户收藏的帖子
export function currentCollectPosts (context) {
    return execute(postApi.currentCollectPosts(), data => {
        context.commit('setCollectPosts', data)
    })
}

// 收藏帖子
export function collectPost (context, payload) {
    return execute(postApi.collectPost(payload))
}

// 取消收藏帖子
export function removeCollectPost (context, payload) {
    return execute(postApi.removeCollectPost(payload))
}

// 设置帖子标签
export function setPostLabels (context, payload) {
    return execute(postApi.setPostLabels(payload))
}

// 获得推送
export function push () {
    return execute(postApi.push())
}

// 搜索
export function searchContent (context, payload) {
    return execute(postApi.searchContent(payload))
}
